<?php
header("content-type:text/html;charset=utf-8"); 
ini_set("magic_quotes_runtime",0);
include_once("../mail/class.phpmailer.php");
require_once(dirname(__FILE__)."/../dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../../admin/libs/config_class.php");

if(!empty($_POST['sub'])){
	$mc=new libstr();
	$cf=new config();
	//提交过来信息
	$name= trim($_POST['name']);
	$email= trim($_POST['email']);
	$phone= trim($_POST['phone']);
	$message= trim($_POST['message']);
	
	//获取后台信息


	//获得网站信息
	$email_info	=	$cf->getInfo('email_info');	
	$smtpport	=	trim($email_info['smtpport']);
	$smtpserver	=	trim($email_info['smtpserver']);
	$smtpemail	=	trim($email_info['smtpemail']);
	$smtppwd	=	trim($email_info['smtppwd']);
	$toemail	=	trim($email_info['toemail']);
	
	

   $body   = "<br />
		<b>姓名</b> : &nbsp;".$name."<br />
		<b>邮箱</b> : &nbsp;".$email."<br />
		<b>电话</b> : &nbsp;".$phone."<br />
		<b>信息</b> : &nbsp;".$message;
	
	$mail             = new PHPMailer();
	$mail->CharSet    = 'UTF-8';
	$mail->IsSMTP(); // telling the class to use SMTP
	$mail->SMTPAuth   = true;                  // enable SMTP authentication
	$mail->Host       = $smtpserver; // SMTP server
	$mail->Port       = $smtpport;                    // set the SMTP port for the GMAIL server
	$mail->Username   = $smtpemail;
	$mail->Password   = $smtppwd;   
	
	$mail->SetFrom($smtpemail, $name);
	$mail->AddReplyTo($email,$name);   //回复地址
	$mail->Subject    = '网站咨询邮件';
	$mail->MsgHTML($body);
	
	$mail->AddAddress($toemail,'你们');
	$mail->Send();
	$mc->msg('succeed!','/contact.php');
}		

?>